import service from '@/alova'
import {invalidateCache} from "alova";

const publicityApi = {
  getList: (data: any) => {
    return service.Get('/api/v1/Publicity/List', {name:'getPublicityList',  params: data });
  },
  getDetail: (id: number) => {
    return service.Get(`/api/v1/Publicity/${id}`);
  },
  del: (id: number) => {
    invalidateCache('getPublicityList');
    return service.Delete(`/api/v1/Publicity/${id}`)
  },
  update: (id: number, data: any) => {
    invalidateCache('getPublicityList');
    invalidateCache(publicityApi.getDetail(id));
    return service.Patch(`/api/v1/Publicity/${id}`, data)
  },
  add: (data: any) => {
    invalidateCache('getPublicityList');
    return service.Post('/api/v1/Publicity', data)
  },
  export: () => {
    return service.Post('/api/v1/Publicity/Export', undefined)
  }
}

export default publicityApi
